package com.shell.provider;

import com.shell.bee.entity.auth.AuthUser;
import com.shell.governor.authentication.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthProvider {
	@Autowired
	private AuthService authService;

	@RequestMapping({ "/auth/getUserByPrincipal" })
	public AuthUser getUserByPrincipal(@RequestParam("userName") String userName) {
		return this.authService.getUserByPrincipal(userName);
	}

	@RequestMapping(value = { "/auth/isMultipleUser" }, method = { RequestMethod.GET })
	public boolean isMultipleUser(@RequestParam("userName") String userName) {
		return this.authService.isMultipleUser(userName);
	}

	@RequestMapping({ "/auth/getLoggedUser" })
	public AuthUser getLoggedUser(@RequestParam("userId") String userId, @RequestParam("entId") String entId,
			@RequestParam("appCode") String appCode, @RequestParam("terminalCode") String terminalCode) {
		return this.authService.getLoggedUser(userId, entId, appCode, terminalCode);
	}
}